package com.lins.common.common.enums;

/**
 * @author Administrator
 * @title: SuccessCode
 * @projectName lins
 * @description: 成功返回的 code
 * @date 2021/12/17 17:52
 */
public enum SuccessCode implements CodeEnum ,Cloneable  {

    // 系统成功码
    SUCCESS(200, "成功", Boolean.TRUE);

    //TODO 增加各类成功返回code
    private int code;
    private String message;
    private Boolean status;

    SuccessCode(int value, String text, Boolean status) {
        this.code = value;
        this.message = text;
        this.status = status;
    }

    @Override
    public int getCode() {
        return code;
    }

    @Override
    public String getMsg() {
        return message;
    }

    @Override
    public void setMessage(String message) {
        this.message = message;
    }

    @Override
    public boolean status() {
        return status;
    }

    @Override
    public CodeEnum fillMessage(String field) {
        String format = String.format(this.getMsg(), field);
        CodeEnum codeEnum = new CodeEnum() {

            @Override
            public int getCode() {
                return code;
            }

            @Override
            public String getMsg() {
                return format;
            }

            @Override
            public boolean status() {
                return status;
            }
        };
        return codeEnum;
    }
}
